package com.codeZ.FactoryPattern.simpleFactory.service.impl;

import cn.hutool.json.JSONUtil;
import com.codeZ.FactoryPattern.entity.AwardInfo;
import com.codeZ.FactoryPattern.entity.ResponseResult;
import com.codeZ.FactoryPattern.entity.SmallGiftInfo;
import com.codeZ.FactoryPattern.simpleFactory.service.IFreeGoods;

import java.util.UUID;

/**
 * 模拟小礼品发放服务
 *
 * @author codeZhang
 * @Date 2024/7/31 17:48
 */
public class SmallGiftFreeGoodsService implements IFreeGoods{
    @Override
    public ResponseResult sendFreeGoods(AwardInfo awardInfo) {
        SmallGiftInfo smallGiftInfo = new SmallGiftInfo();
        smallGiftInfo.setUserPhone(awardInfo.getExtMap().get("phone" ));

        smallGiftInfo.setUserName(awardInfo.getExtMap().get("username"));

        smallGiftInfo.setAddress(awardInfo.getExtMap().get("address" ));

        smallGiftInfo.setOrderId(UUID.randomUUID().toString());

        System.out.println("小礼品发放成 ,请注意查收: " + JSONUtil.toJsonPrettyStr(smallGiftInfo));
        return new ResponseResult("200","小礼品发送成 功",smallGiftInfo);
    }
}
